<?php
    
    
    if ( isset($_GET["email"])  && isset($_GET["senha"]) && isset($_GET["sexo"]) && isset($_GET["dtnasc"]) ){
        $email = $_GET["email"];
        $senha = $_GET["senha"];
        $sexo = $_GET["sexo"];
        $dtnasc = $_GET["dtnasc"];
        
        $result = cadastro( $email, $senha, $sexo, $dtnasc );
        echo $result;
    }

    
    function makeSqlConnection()
    {
        $DB_HostName = "localhost";
        $DB_Name = "ios";
        $DB_User = "root";
        $DB_Pass = "root";
        
        $con = mysql_connect($DB_HostName,$DB_User,$DB_Pass) or die(mysql_error());
        
		mysql_select_db($DB_Name,$con) or die(mysql_error());
        
        return $con;
    }
    
    function disconnectSqlConnection($con)
    {
        mysql_close($con);
    }
    
    function cadastro($email, $senha, $sexo, $dtnasc )
    {
        //require (FILE);
        $con = makeSqlConnection();
        
        $sql = "INSERT INTO tb_cadastro(email,senha,sexo,dtnasc,dtcad ) VALUES('$email', '$senha', '$sexo','$dtnasc',current_timestamp)";
        
        $res = mysql_query($sql,$con) or die(mysql_error());
        
        //echo "sql  = $sql";
        
        $res1 = mysql_affected_rows();
        
        //echo "<br> bbbb res1  = $res1";
        
        disconnectSqlConnection($con);
        
        if ($res1 != 0) {
            //echo "<br>vvvv res1  = $res1";
            return 1;
        }else{
            //echo "<br>xxxxx res1  = $res1";
            return 0;
        }// end else
        
        
    }// end of Function 
    
    ?>